import {request} from './request.js'
export function Login(uname,pwd){
	return request({
		url:'/api/login',
		method:'post',
		data:{
			username:uname,
			password:pwd
		},
		transformRequest: [function(data) {
		
		                let ret = ''
		                for(let it in data) {
		                    ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
		                }
		                return ret
		            }],
		headers: {
		        'Content-Type': 'application/x-www-form-urlencoded'
		}
	})
} 
// export const Login = (params, headers) => post("/api/login/", params, headers)
export function regUser(body){	
	// console.log(body.nickname)
	return request({
		url:'/api/reguser',
		method:'post',
		data:{
			username:body.username,
			password:body.password,
			nickname:body.nickname,
			email:body.email,
			age:body.age,
			},
		transformRequest: [function(data) {
		
		                let ret = ''
		                for(let it in data) {
		                    ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
		                }
		                return ret
		            }],
		headers: {
		        'Content-Type': 'application/x-www-form-urlencoded'
		}
	})
} 